package 算法.leetcode.bytedance;

import 算法.leetcode.offer.base.ListNode;

/**
 * @author lchenglong
 * @date 2022/5/7
 */
public class OfferNode_II {
    public ListNode reverseList(ListNode head) {
        // 边界条件
        if (head == null||head.next == null)return head;
        ListNode pre = null;
        while (head!=null){
            ListNode tmp = head.next;
            head.next = pre;
            pre = head;
            if (tmp == null)break;
            head = tmp;
        }
        return head;
    }
}
